package
{
	public class Forma
	{
		private var _type:String;
		//Un vector donde se guardan los 4 bloques que determinan la forma
		private var _blocks:Vector.<Block>;
		//Constantes para definir el tipo de forma
		public static const I:String = "I";
		public static const J:String = "J";
		public static const L:String = "L";
		public static const O:String = "O";
		public static const S:String = "S";
		public static const Z:String = "Z";
		public static const T:String = "I";
		
		public function Forma(type:String)
		{
			this._type = type;
			this._blocks = new Vector.<Block>();
			this.generarGrupo()
		}
		
		public function set type(value:String):void
		{
			this._type = value;
		}
		
		public function get type():String
		{
			return this._type;
		}
		/**
		 * Obtiene el bloque indicado por el indice
		 */
		public function getBlock(index:uint):Block
		{
			return this._blocks[index];
		}
		/**
		 * De acuerdo al tipo de la forma, genero un bloque con las coordenadas correspondientes en cada indice
		 */		
		private function generarGrupo():void			
		{
			switch(this._type)
			{
				case Forma.I:
					this._blocks[0] = new Block(0,0,this._type);
					this._blocks[1] = new Block(1,0,this._type);
					this._blocks[2] = new Block(2,0,this._type);
					this._blocks[3] = new Block(3,0,this._type);
					break;
				case Forma.J:
					this._blocks[0] = new Block(0,0,this._type);
					this._blocks[1] = new Block(0,1,this._type);
					this._blocks[2] = new Block(1,1,this._type);
					this._blocks[3] = new Block(2,1,this._type);
					break;				
				case Forma.L:
					this._blocks[0] = new Block(2,0,this._type);
					this._blocks[1] = new Block(0,1,this._type);
					this._blocks[2] = new Block(1,1,this._type);
					this._blocks[3] = new Block(2,1,this._type);
					break;
				case Forma.O:
					this._blocks[0] = new Block(0,0,this._type);
					this._blocks[1] = new Block(1,0,this._type);
					this._blocks[2] = new Block(0,1,this._type);
					this._blocks[3] = new Block(1,1,this._type);
					break;				
				case Forma.S:
					this._blocks[0] = new Block(1,0,this._type);
					this._blocks[1] = new Block(2,0,this._type);
					this._blocks[2] = new Block(1,1,this._type);
					this._blocks[3] = new Block(0,1,this._type);
					break;				
				case Forma.Z:
					this._blocks[0] = new Block(0,0,this._type);
					this._blocks[1] = new Block(1,0,this._type);
					this._blocks[2] = new Block(1,1,this._type);
					this._blocks[3] = new Block(2,1,this._type);
					break;				
				case Forma.T:
					this._blocks[0] = new Block(1,0,this._type);
					this._blocks[1] = new Block(0,1,this._type);
					this._blocks[2] = new Block(1,1,this._type);
					this._blocks[3] = new Block(2,1,this._type);
					break;				
			}
		}
	}
}